#!/usr/bin/python
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

url = "https://www.sina.com.cn"
chrome_options = Options()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
browser = webdriver.Chrome(r'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\chromedriver.exe',chrome_options=chrome_options)
browser.set_page_load_timeout(300)
browser.set_script_timeout(300)
browser.get(url)

# Get the actual page dimensions using javascript
width = browser.execute_script(" return Math.max(document.body.scrollWidth,document.body.offsetWidth, document.documentElement.clientWidth, document.documentElement.scrollWidth, document.documentElement.offsetWidth);")
		 
height = browser.execute_script("return Math.max(document.body.scrollHeight, document.body.offsetHeight,document.documentElement.clientHeight, document.documentElement.scrollHeight, document.documentElement.offsetHeight);")

#resize
browser.set_window_size(width,height)
time.sleep(3)

browser.get_screenshot_as_file("./sina.png")
browser.quit()
